const CONSTANTS = {
  /** 用户列表请求中 */
  LIST_FETCHING: 'USERS/LIST_FETCHING',
  /** 用户列表请求成功 */
  LIST_FETCHING_SUCCESS: 'USERS/LIST_FETCHING_SUCCESS',
  /** 用户列表请求失败 */
  LIST_FETCHING_FAIL: 'USERS/LIST_FETCHING_FAIL',
};

const initialState: SysUser.State = {
  /** 用户列表数据 */
  userListData: [],
  isListFetching: false,
};

const sysUserReducer = (state: SysUser.State, action: any) => {
  let newState = {};
  switch (action.type) {

    /** 用户列表请求中 */
    case CONSTANTS.LIST_FETCHING:
      newState = { isListFetching: true };
      break;

    /** 用户列表请求成功 */
    case CONSTANTS.LIST_FETCHING_SUCCESS:
      newState = { isListFetching: false};
      break;
    /** 用户列表请求失败 */
    case CONSTANTS.LIST_FETCHING_FAIL:
      newState = { isListFetching: false};
      break;

    default:
      newState = initialState;
      break;
  }

  return Object.assign({}, state, newState);
};

export default sysUserReducer;